<?php
namespace Home\Controller;


class LeaveController extends HomeController {


	public function _initialize(){
			parent::_initialize();
			$this->_model = M('leave');
		}
    //主页列表
    public function index(){
        $m=M('leave');
        //搜索
        if($_GET['g']){
            $keywordG = $_GET['g'];  //获取搜索关键字 
            $where['ltalkid'] = array('eq',$keywordG);    
        }

        //分页 这个函数在app下的com下com里
        $p=getpage($m,$where,8);
        $talkid=$m->distinct(true)->field('ltalkid')->where($where)->select();
        $lista=$m->field(true)->where($where)->select();
        // dump($lista);exit;
        
        $this->assign('lista',$lista);
       
        $this->assign('talkid',$talkid);
        $this->page=$p->show();
        $this->display();
    }
  		public function del(){
			if($this->_model->delete($_GET['id']) > 0){
				$this->success("删除成功！",U('Leave/index'));
			}else{
				$this->error("删除失败");
			}
		}
   }
